<template>
	<view class="blue" :class="{ light: theme == 'light' }">
		<view class="plr20 pt20 pb15 bgPart">
			<text class="bold ft18 blue2" v-if="coinInfo.currency">{{ coinInfo.currency.code }}</text>
			<view class="mt10 flex alcenter mt15">
				<view class="flex1">
					<view class="blue ft12">{{ this.$t('trade.use') }}</view>
					<view class="mt5 ft12 ">{{ coinInfo.balance }}</view>
				</view>
				<view class="flex1 tc">
					<view class="blue ft12">{{ $t('assets.lock') }}</view>
					<view class="mt5 ft12 ">{{ coinInfo.frozenBalance }}</view>
				</view>
				<view class="flex1 tr">
					<view class="blue ft12">{{ $t('assets.zhehe') }}(USDT)</view>
					<view class="mt5">{{ (coinInfo.balance-0)*(coinInfo.coin.usdRate-0)| filterDecimals }}</view>
				</view>
			</view>
		</view>
		<!-- <view class="bgHeader h10"></view> -->
		<view class="plr10 ptb15 mt10 bgPart" style="min-height: 80vh;">
			<!-- 财务记录 -->
			<view class="ft16">{{ $t('assets.records') }}</view>
			<view class="mt10 pb100">
				<view class="flex alcenter ptb10 bdb_blue3 ">
					<view class="flex1">{{ $t('trade.num') }}</view>
					<view class="flex1 ">{{ $t('assets.record') }}</view>
					<view class="flex1 tr">{{ $t('trade.time') }}</view>
				</view>
				
				<view class="mt10 flex bdb_blue3 ptb5" v-for="(item, i) in logList" :key="i" v-if="logList.length > 0">
					<view class="flex1">{{ item.amount - 0 }}</view>
					<view class="flex1 wordbreak pr10">{{ item.type }}</view>
					<view class="flex1 tr">{{ item.createTime }}</view>
				</view>
				
				<view class="mt20 tc" v-if="logList.length == 0">
					<image src="../../static/image/anonymous.png" class="wt60 h60"></image>
					<view>{{ $t('home.norecord') }}</view>
				</view>
				<view class="tc gray7 ptb20" v-show="!hasMore && logList.length > 0">{{ $t('home.nomore') }}</view>
			</view>
		</view>
		
		<view class="fixed pos_l0b0 w100 bgHeader bdt2f flex alcenter ptb10 zdx100">
			<!-- 币币账户 -->
			<block>
			<!-- 	<navigator :url="'transfer?accountTypeId=' + coinInfo.account_type_id+'&id='+coinInfo.id+'&account_code='+coinInfo.account_type.account_code" class="flex1 tc" v-if="changeTransfer == 1">
					<image src="../../static/image/hz01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.transfer') }}</view>
				</navigator> -->
				<!-- 充币 -->
				<navigator
					:url="'charge?symbol=' + symbol"
					class="flex1 tc"
					v-if="coinInfo.coin && coinInfo.coin.canRecharge == 1"
				>
					<image src="../../static/image/cb01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.charge') }}</view>
				</navigator>
				<!-- 提币 -->
				<navigator
					:url="'mention?currency=' + symbol" 
					class="flex1 tc"
					v-if="coinInfo.coin && coinInfo.coin.canWithdraw == 1"
				>
					<image src="../../static/image/tb01.png" class="wt30 h30"></image>
					<view class="">{{ $t('assets.mention') }}</view>
				</navigator>
			</block>
			<!-- 法币账户 -->
			<block v-if="tradeType == 'legal_account' && coinInfo.account_type&&coinInfo.account_type.is_recharge == 1">
				<navigator :url="'transfer?accountTypeId=' + coinInfo.account_type_id+'&id='+coinInfo.id" class="flex1 tc" v-if="legalTransfer == 1">
					<image src="../../static/image/hz01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.transfer') }}</view>
				</navigator>
				<!-- 充币 -->
				<navigator
					:url="'charge?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_recharge == 1"
				>
					<image src="../../static/image/cb01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.charge') }}</view>
				</navigator>
				<!-- 提币 -->
				<navigator
					:url="'mention?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + account_id +'&account_type_id='+coinInfo.account_type_id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_draw == 1"
				>
					<image src="../../static/image/tb01.png" class="wt30 h30"></image>
					<view class="">{{ $t('assets.mention') }}</view>
				</navigator>
			</block>
			<!-- 杠杠账户 -->
			<block v-if="tradeType == 'lever_account' && coinInfo.account_type&&coinInfo.account_type.is_recharge == 1">
				<navigator :url="'transfer?accountTypeId=' + coinInfo.account_type_id+'&id='+coinInfo.id" class="flex1 tc" v-if="leverTransfer == 1">
					<image src="../../static/image/hz01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.transfer') }}</view>
				</navigator>
				<!-- 充币 -->
				<navigator
					:url="'charge?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_recharge == 1"
				>
					<image src="../../static/image/cb01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.charge') }}</view>
				</navigator>
				<!-- 提币 -->
				<navigator
					:url="'mention?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + account_id +'&account_type_id='+coinInfo.account_type_id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_draw == 1"
				>
					<image src="../../static/image/tb01.png" class="wt30 h30"></image>
					<view class="">{{ $t('assets.mention') }}</view>
				</navigator>
			</block>
			<!-- 秒合约账户 -->
			<block v-if="tradeType == 'micro_account' && coinInfo.account_type&&coinInfo.account_type.is_recharge == 1">
				<navigator :url="'transfer?accountTypeId=' + coinInfo.account_type_id+'&id='+coinInfo.id" class="flex1 tc" v-if="microTransfer == 1">
					<image src="../../static/image/hz01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.transfer') }}</view>
				</navigator>
				<!-- 充币 -->
				<navigator
					:url="'charge?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_recharge == 1"
				>
					<image src="../../static/image/cb01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.charge') }}</view>
				</navigator>
				<!-- 提币 -->
				<navigator
					:url="'mention?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + account_id +'&account_type_id='+coinInfo.account_type_id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_draw == 1"
				>
					<image src="../../static/image/tb01.png" class="wt30 h30"></image>
					<view class="">{{ $t('assets.mention') }}</view>
				</navigator>
			</block>
			<!-- 杠杠账户 -->
			<block v-if="tradeType == 'lsolated_lever' && coinInfo.account_type&&coinInfo.account_type.is_recharge == 1">
				<navigator :url="'transfer?accountTypeId=' + coinInfo.account_type_id+'&id='+coinInfo.id" class="flex1 tc" v-if="isoTransfer == 1">
					<image src="../../static/image/hz01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.transfer') }}</view>
				</navigator>
				<!-- 充币 -->
				<navigator
					:url="'charge?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_recharge == 1"
				>
					<image src="../../static/image/cb01.png" class="wt30 h30 "></image>
					<view class="">{{ $t('assets.charge') }}</view>
				</navigator>
				<!-- 提币 -->
				<navigator
					:url="'mention?currency=' + currency_id + '&name=' + coinInfo.currency.code + '&id=' + account_id +'&account_type_id='+coinInfo.account_type_id"
					class="flex1 tc"
					v-if="coinInfo.currency && coinInfo.currency.open_draw == 1"
				>
					<image src="../../static/image/tb01.png" class="wt30 h30"></image>
					<view class="">{{ $t('assets.mention') }}</view>
				</navigator>
			</block>
		</view>
	</view>
</template>

<script>
const map = {
    "0":"充值",
    "1":"提现",
    "2":"转账",
    "3":"币币交易",
    "4":"法币买入",
    "5":"法币卖出",
    "6":"活动奖励",
    "7":"推广奖励",
    "8":"分红",
    "9":"投票",
    "10":"充值",
    "11":"配对",
    "12":"缴纳商家认证保证金",
    "13":"退回商家认证保证金",
    "14":"法币充值",
    "15":"币币兑换",
    "16":"渠道推广",
    "17":"划转入杠杆钱包",
    "18":"从杠杆钱包划转出",
    "19":"钱包空投",
    "20":"锁仓",
    "21":"解锁",
    "22":"第三方转入",
    "23":"第三方转出",
    "24":"币币转入法币",
    "25":"法币转入币币",
    "26":"借贷流水",
    "27":"还款流水",
    "28":"兑换IOTH"
};
const mapJp = {
    "0":"リチャージ",
     "1":"撤回",
     "2":"転送",
     "3":"通貨トランザクション",
     "4":"フィアット通貨購入",
     "5":"フィアット通貨販売",
     "6":"アクティビティ報酬",
     "7":"プロモーション報酬",
     "8":"配当",
     "9":"投票",
     "10":"手動再充電",
     "11":"ペアリング",
     "12":"販売者証明書のデポジットを支払う",
     "13":"返品確認デポジット",
     "14":"ファットマネーリチャージ",
     "15":"通貨交換",
     "16":"チャンネルプロモーション",
     "17":"レバレッジドウォレットへの転送",
     "18":"レバレッジドウォレットからの転送",
     "19":"Wallet Airdrop",
     "20":"ロック位置",
     "21":"ロック解除",
     "22":"サードパーティの転送",
     "23":"サードパーティの転送",
     "24":"法定通貨への通貨振替",
     "25":"フィアット通貨から通貨通貨へ",
     "26":"ローンフロー",
     "27":"返済フロー"
};
const mapKo = {
     "0":"충전",
      "1":"출금",
      "2":"Transfer",
      "3":"통화 거래",
      "4":"명목 화폐 구매",
      "5":"피아트 화폐 판매",
      "6":"활동 보상",
      "7":"프로모션 보상",
      "8":"배당금",
      "9":"투표",
      "10":"수동 충전",
      "11":"페어링",
      "12":"가맹점 인증 입금 결제",
      "13":"판매자 확인 입금 반환",
      "14":"뚱뚱한 돈 충전",
      "15":"환전",
      "16":"채널 프로모션",
      "17":"레버리지 지갑으로 이체",
      "18":"레버리지 지갑에서 송금",
      "19":"지갑 에어 드랍",
      "20":"잠금 위치",
      "21":"Unlock",
      "22":"제 3 자 입금",
      "23":"제 3 자 전출",
      "24":"법정 통화로 통화 이체",
      "25":"피아트 통화를 통화 통화로",
      "26":"대출 흐름",
      "27":"상환 흐름"
};
const mapEn = {
    "0":"recharge",
    "1":"withdraw deposit",
    "2":"transfer",
    "3":"currency deal",
    "4":"legal tender buying",
    "5":"legal tender selling",
    "6":"activity reward",
    "7":"Promotion rewards",
    "8":"dividend",
    "9":"voting",
    "10":"Artificial Recharge",
    "11":"pairing",
    "12":"pay the merchant certification deposit",
    "13":"Return the merchant certification deposit",
    "14":"legal tender recharge",
    "15":"currency exchange",
    "16":"Channel promotion",
    "17":"Transfer to lever wallet",
    "18":"Transfer out of the lever wallet",
    "19":"wallet airdrop",
    "20":"locked position",
    "21":"unlock",
    "22":"Third party transfer",
    "23":"Third party roll out",
    "24":"The bitcoins are transferred into legal tender",
    "25":"Legal tender is transferred into bitcoin",
    "26":"loan flow",
    "27":"repayment flow",
    "28":"exchange IOTH"
};	
import { mapState } from 'vuex';
export default {
	data() {
		return {
			currency: '',
			tradeType: '',
			page: 1,
			isBottom: false,
			hasMore: true,
			coinInfo: {},
			logList: [],
			titles: ['账户信息', this.$t('assets.leveracc'), this.$t('assets.legalacc'),this.$t('assets.microacc'),this.$t('assets.isoacc')],
			// titles: [this.$t('assets.tradeacc'), this.$t('assets.leveracc'), this.$t('assets.legalacc'),this.$t('assets.microacc'),this.$t('assets.isoacc')],
			ExRate: 6.5,
			id: '',
			symbol: '',
			logurl: '',
			changeTransfer: 0,
			legalTransfer: 0,
			leverTransfer: 0,
			microTransfer: 0,
			isoTransfer: 0,
		};
	},
	computed: {
		...mapState(['theme'])
	},
	onShow() {
		this.$utils.setThemeTop(this.theme);
		// this.$utils.setThemeBottom(this.theme)
	},
	onLoad(e) {
		console.log(e);
		this.id = e.id;
		this.symbol = e.symbol;
		this.getDetail();
		var that = this;
		this.getLog();
		uni.setNavigationBarTitle({
			title:this.$t('legal').list
		})
	},
	methods: {
		getDetail() {
			var that = this;
			that.$utils.initDataToken({ url: 'uc/asset/wallet/'+that.symbol, data: { } }, res => {
				uni.stopPullDownRefresh();
				that.coinInfo = res;
			});
		},
		goTrade() {
			let localData = uni.getStorageSync('tradeData') || {};
			let currency_name = this.coinInfo.currency_name;
			console.log(uni.getStorageSync('tradeData'), localData);
			if (localData.legal_name && localData.legal_name != currency_name) {
				console.log(123);
				localData.currency_name = currency_name;
				localData.currency_id = this.currency_id;
				uni.setStorageSync('tradeData', localData);
			}
			uni.switchTab({
				url: '/pages/trade/trade'
			});
		},
		getLog() {
			let that = this;
			let lang = uni.getStorageSync('lang') || 'en';
			let m = map;
			if(lang == "en"){
				m = mapEn;
			}else{
				m = map;
			}
			let url = 'uc/asset/transaction' + this.logurl;
			this.$utils.initDataToken({ url: url, data: { symbol: this.symbol, pageNo: this.page, pageSize: 15 } }, res => {
				uni.stopPullDownRefresh();
				let data = res.content;
				data.forEach(function(value,index){
					value.type = m[value.type];
				});
				that.isBottom = false;
				that.logList = that.page == 1 ? data : that.logList.concat(data);
				that.hasMore = res.last_page == res.current_page ? false : true;
			});
		}
	},
	onPullDownRefresh() {
		this.page = 1;
		(this.bottom = false), (this.hasMore = true), this.getLog();
		this.getDetail();
	},
	onReachBottom() {
		if (!this.hasMore) return;
		this.page++;
		this.getLog();
	}
};
</script>

<style></style>
